package com.model.defaults.tabsheet;

import java.util.Map;

import org.hibernate.Session;

import com.core.GlobalConstants;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.TabSheetItem;
import com.model.UserContextName;


public class ModelDefaultTabsheetAdministration {

    public static void createTabsheetItemsAdministration ( Session session,
                                                           Map <String, UserContextName> userContexts ) {

        /*
         * BrowseAdministration
         */

        TabSheetItem pojo = null;
        UserContextName contextName_1 = null;
        ActionScript actionScript = null;
        KeyValue actionScriptParam = null;

        actionScriptParam = new KeyValue("selectedTab", "selectedTab=1");
        session.save(actionScriptParam);

        actionScript = new ActionScript();
        actionScript.setActionScriptText("BrowseAdministration?{selectedTab}");
        actionScript.setActionScriptType("servlet");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
        pojo = new TabSheetItem();
        pojo.setName("BrowseAdministration.Summary");
        pojo.setCaption("Users");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("BrowseAdministration#Summary");
        pojo.setServletNameToExecute(GlobalConstants.SERVLET_ADMINISTRATION);
        pojo.setJspNameInContext("details/tabUsersList.jsp");
        pojo.setIsDefault(true);
        pojo.setActionScript(actionScript);
        session.save(pojo);


        /**
         * User Groups
         */

        actionScriptParam = new KeyValue("selectedTab", "selectedTab=2");
        session.save(actionScriptParam);

        actionScript = new ActionScript();
        actionScript.setActionScriptText("BrowseAdministration?{selectedTab}");
        actionScript.setActionScriptType("servlet");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
        pojo = new TabSheetItem();
        pojo.setName("BrowseAdministration.Agile");
        pojo.setCaption("Groups");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/tabUserGroups.jsp");
        pojo.setServletNameToExecute(GlobalConstants.SERVLET_ADMINISTRATION);
        pojo.setActionScript(actionScript);
        session.save(pojo);

        /**
         * User Roles
         */

        actionScriptParam = new KeyValue("selectedTab", "selectedTab=3");
        session.save(actionScriptParam);

        actionScript = new ActionScript();
        actionScript.setActionScriptText("BrowseAdministration?{selectedTab}");
        actionScript.setActionScriptType("servlet");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
        pojo = new TabSheetItem();
        pojo.setName("BrowseAdministration.Agile");
        pojo.setCaption("Roles");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/tabUserRoles.jsp");
        pojo.setServletNameToExecute(GlobalConstants.SERVLET_ADMINISTRATION);
        pojo.setActionScript(actionScript);
        session.save(pojo);

        /**
         * Custom DB actions
         */

        actionScriptParam = new KeyValue("selectedTab", "selectedTab=4");
        session.save(actionScriptParam);

        actionScript = new ActionScript();
        actionScript.setActionScriptText("BrowseAdministration?{selectedTab}");
        actionScript.setActionScriptType("servlet");
        actionScript.getParams().add(actionScriptParam);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_ADMINISTRATION);
        pojo = new TabSheetItem();
        pojo.setName("BrowseAdministration.Agile");
        pojo.setCaption("DB Actions");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/tabDBActions.jsp");
        pojo.setServletNameToExecute(GlobalConstants.SERVLET_ADMINISTRATION);
        pojo.setActionScript(actionScript);
        session.save(pojo);

    }

}
